package com.itlong.cloud.controller.settings;


import com.itlong.cloud.POJO.DTO.property.PropertyProjectGetPropertyInfoBrowseStatusDTO;
import com.itlong.cloud.POJO.DTO.property.PropertyProjectGetPropertyInfoDTO;
import com.itlong.cloud.POJO.VO.MessageVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectPropertyInfoAndBrowseStatusVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectPropertyInfoBrowseStatusVO;
import com.itlong.cloud.POJO.VO.property.PropertyProjectPropertyInfoVO;
import com.itlong.cloud.PlatformConstants;
import com.itlong.cloud.abstracts.BaseController;
import com.itlong.cloud.annotation.AuthAccessRequired;
import com.itlong.cloud.annotation.LoggerInfo;
import com.itlong.cloud.constants.LogDescConstant;
import com.itlong.cloud.enumerate.FileCatalogEnum;
import com.itlong.cloud.enumerate.PropertyInfoTypeEnum;
import com.itlong.cloud.enumerate.ecode.BaseErrorCodeEnum;
import com.itlong.cloud.enumerate.ecode.OperateErrorCodeEnum;
import com.itlong.cloud.enumerate.ecode.PropertyErrorCodeEnum;
import com.itlong.cloud.noncore.commons.IUploadImageServiceClient;
import com.itlong.cloud.project.property.IPropertyPropertyInfoServiceClient;
import com.itlong.cloud.thrown.DataAccessException;
import com.itlong.cloud.utils.file.UploadFileUtil;
import com.itlong.cloud.utils.network.http.HttpProtocolUtil;
import com.itlong.cloud.utils.page.Page;
import com.itlong.cloud.utils.words.StringHandlerUtil;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import javax.servlet.http.HttpServletRequest;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;


/**
 * <desc>
 *    物业投诉、物业报修、物业通知与便民信息 管理控制器
 * </desc>
 *
 * @createDate 2017-10-16
 */
@RestController
@RequestMapping("settings/propertyInfo")
@RefreshScope
public class PropertyNoticeAndConvenienceController extends BaseController{

    @Autowired
    IPropertyPropertyInfoServiceClient iPropertyPropertyInfoServiceClient;

    @Autowired
    IUploadImageServiceClient iUploadImageServiceClient;


    @Value("${" + PlatformConstants.FILE_FTP_HOST + "}")
    public String FILE_FTP_HOST;

    @Value("${" + PlatformConstants.FILE_FTP_PORT + "}")
    public String FILE_FTP_PORT;

    @Value("${" + PlatformConstants.FILE_FTP_USERNAME + "}")
    public String FILE_FTP_USERNAME;

    @Value("${" + PlatformConstants.FILE_FTP_PASSWORD + "}")
    public String FILE_FTP_PASSWORD;

    @Value("${" + PlatformConstants.FILE_ACCESS_URL + "}")
    public String FILE_ACCESS_URL;


    /**
     * <desc>
     *      上传图片资源。
     * <desc/>
     *
     * @param  httpServletRequest 图片http请求
     * @return
     * @author ZiXuan
     * @createDate 2017-10-24
     */
    @LoggerInfo(operateDesc = LogDescConstant.UPLOAD_AD_IMAGE_LOG_DESC)
    @RequestMapping(path = "/uploadImg" , method = RequestMethod.POST)
    @ResponseBody
    public Object uploadImg(HttpServletRequest httpServletRequest){
        MessageVO messageVO;

        String imgUrl = ""; //返回图片链接地址
        String imgBase64 ="";  //图片base64编码字符串
        String imgExt = "jpg|jpeg|png|bmp|BMP|GIF|JPG|PNG|JPEG";
        try{
//            String imgData = httpServletRequest.getParameter("imgData");
//            if(StringUtils.isEmpty(imgData)){
//                return new MessageVO(OperateErrorCodeEnum.IMAGE_RESOURCE_EMPTY_ERR.getErrorCode());
//            }
//            String imgType = imgData.substring(imgData.indexOf("/") + 1, imgData.indexOf(";"));
//
//            if((StringUtils.isEmpty(imgType))||(!imgExt.contains(imgType))){
//                return new MessageVO(OperateErrorCodeEnum.IMAGE_TYPE_ANVALID_ERR.getErrorCode());
//            }
//            imgBase64 = imgData.substring(imgData.indexOf(",") + 1, imgData.length());
//            UploadImageDTO saveDTO  = new UploadImageDTO();
//            saveDTO.setImgBase64(imgBase64);
//            saveDTO.setImgType(imgType);
//            imgUrl = iUploadImageServiceClient.uploadImg(saveDTO);
//            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),"",imgUrl);

            boolean isMultipart = ServletFileUpload.isMultipartContent(httpServletRequest);
            if (!isMultipart) {
                //是否是带文件上传的表单
                return new MessageVO(PropertyErrorCodeEnum.EQUIP_MEDIA_RESOURCE_EMPTY_ERR.getErrorCode());
            }
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) httpServletRequest;
            MultipartFile file = multipartRequest.getFiles("imgData").get(0);
            InputStream fileStream = file.getInputStream();
            String fileName = file.getOriginalFilename();
            String fileType = StringHandlerUtil.copySubStr(fileName, fileName.lastIndexOf('.') + 1, fileName.length());
            if (StringUtils.isBlank(fileType) || (!imgExt.contains(fileType))) {
                return new MessageVO(OperateErrorCodeEnum.IMAGE_TYPE_ANVALID_ERR.getErrorCode());
            }

            imgUrl = this.uploadFile(fileStream, fileName);
            messageVO = new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(),"",imgUrl);
            if (null != messageVO)
            {
                return messageVO;
            }
        } catch (Exception e){
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】上传图片资源失败",e);
        }
        return messageVO;
    }


    /**
     * <desc>
     *    Ftp上传文件，返回Url.
     * </desc>
     *
     * @param stream 文件流
     * @return 文件上传成功后会返回Url,否则返回空
     * @author ZiXuan
     * @createDate 2017-11-30
     */
    private String uploadFile(InputStream stream, String fileName) throws Exception{

        String fileType = StringHandlerUtil.copySubStr(fileName, fileName.lastIndexOf('.'), fileName.length());
        UploadFileUtil.UploadFile uploadFileUtil = new UploadFileUtil().new UploadFile(
                FILE_FTP_HOST,
                FILE_FTP_USERNAME,
                FILE_FTP_PASSWORD,
                FILE_FTP_PORT,
                stream,
                fileType,
                FILE_ACCESS_URL,
                FileCatalogEnum.CONVENIENCEINFO_FILE.getType()
        );
        Map<String, Object> resultMap = null;
        try {

            resultMap = UploadFileUtil.uploadFile(uploadFileUtil);

        }catch (Exception e){
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】保存图片失败", e);
        }

        String fileUrl = "";
        if ("true".equals(resultMap.get("returnCode").toString())){
            fileUrl = resultMap.get("accessPath").toString();
        }
        return fileUrl;
    }


    /**
     * <desc>
     *      单条查询 物业信息
     * <desc/>
     *
     * @param propertyInfoId 查询参数
     * @return
     * @author ZiXuan
     * @createDate 2017-12-01
     */
    @RequestMapping(path = "/getOnePropertyInfo",method = {RequestMethod.POST})
    @ResponseBody
    @AuthAccessRequired
    public Object getOnePropertyInfo(String propertyInfoId) {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyInfoId = request.getAttribute("propertyInfoId") == null ? null : request.getAttribute("propertyInfoId").toString();
            //信息编号
            if(StringUtils.isBlank(propertyInfoId)){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_ID_EMPTY_ERR.getErrorCode());
            }
            PropertyProjectPropertyInfoVO propertyProjectPropertyInfoVO = iPropertyPropertyInfoServiceClient.getOnePropertyInfo(propertyInfoId);

            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), propertyProjectPropertyInfoVO);

        } catch (Exception e) {
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】单条查询物业信息失败", e);
        }
    }

    /**
     * <desc>
     *      查询物业信息
     * <desc/>
     * @param  pageDTO 查询物业信息数据传输对象
     * @return 物业信息 返回对象
     * @author ZiXuan
     * @createDate 2017-10-16
     */
    @RequestMapping(path = "/getPage",method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object getPage(PropertyProjectGetPropertyInfoDTO pageDTO){
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            pageDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetPropertyInfoDTO.class, request);
            if (null == pageDTO){
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            //项目编号
            if(StringUtils.isBlank(pageDTO.getProjectId())){
                return new MessageVO(PropertyErrorCodeEnum.PUB_PROJECT_ID_EMPTY_ERR.getErrorCode());
            }

            //物业信息 类型判断
            if((null != pageDTO.getPropertyType()) && (pageDTO.getPropertyType() != PropertyInfoTypeEnum.NOTICE_INFO.getType() &&
                    pageDTO.getPropertyType() != PropertyInfoTypeEnum.CONVENIENCE_INFO.getType())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_TYPE_INVALID_ERR.getErrorCode());
            }

            Page<PropertyProjectPropertyInfoVO> page = new Page<>();
            List<Integer> propertyTypeList = new ArrayList<>();

            if (null == pageDTO.getPropertyType()){        //默认查询报修和投诉
                propertyTypeList.add(PropertyInfoTypeEnum.NOTICE_INFO.getType());
                propertyTypeList.add(PropertyInfoTypeEnum.CONVENIENCE_INFO.getType());
            }
            else
            {
                propertyTypeList.add(pageDTO.getPropertyType());
            }

            pageDTO.setPropertyTypeList(propertyTypeList);

            page = iPropertyPropertyInfoServiceClient.getPage(pageDTO);

            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), page);

        } catch (Exception e) {
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】分页查询物业信息失败", e);
        }
    }

    /**
     * <desc>
     *      保存物业信息
     * <desc/>
     * @param  propertyDTO 物业信息数据传输对象
     * @return
     * @author ZiXuan
     * @createDate 2017-10-26
     */
    @LoggerInfo(operateDesc = LogDescConstant.SAVE_PROPERTYINFO_LOG_DESC)
    @RequestMapping(path = "/savePropertyInfo",method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object savePropertyInfo(PropertyProjectGetPropertyInfoDTO propertyDTO){
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetPropertyInfoDTO.class, request);
            if (null == propertyDTO){
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            //项目编号
            if(StringUtils.isBlank(propertyDTO.getProjectId())){
                return new MessageVO(PropertyErrorCodeEnum.PUB_PROJECT_ID_EMPTY_ERR.getErrorCode());
            }
            //物业信息 类型判断
            if((null == propertyDTO.getPropertyType()) || (propertyDTO.getPropertyType() != PropertyInfoTypeEnum.CONVENIENCE_INFO.getType() &&
                    propertyDTO.getPropertyType() != PropertyInfoTypeEnum.NOTICE_INFO.getType())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_TYPE_INVALID_ERR.getErrorCode());
            }
            //物业标题
            if(StringUtils.isBlank(propertyDTO.getTitle())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_TITLE_EMPTY_ERR.getErrorCode());
            }
            if(propertyDTO.getTitle().length() > 30){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_TITLE_LENGTH_INVALID_ERR.getErrorCode());
            }
            //物业内容
            if(StringUtils.isBlank(propertyDTO.getPropertyInfo())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_EMPTY_ERR.getErrorCode());
            }

//            //图片不为空 则上传图片
//            if (!StringUtils.isBlank(propertyDTO.getImgData())){
//                MessageVO messageVO = uploadImg(propertyDTO.getImgData());
//                if (messageVO.getMsgCode() != 0){
//                    return messageVO;
//                }
//                //记录图片url
//                propertyDTO.setImgUrl(messageVO.getData().toString());
//            }
            iPropertyPropertyInfoServiceClient.savePropertyInfo(propertyDTO);
            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode());

        } catch (Exception e) {
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】保存物业信息失败", e);
        }
    }

    /**
     * <desc>
     *      修改物业信息
     * <desc/>
     * @param  propertyDTO 修改物业信息数据传输对象
     * @return
     * @author ZiXuan
     * @createDate 2017-10-26
     */
    @LoggerInfo(operateDesc = LogDescConstant.UPDATE_PROPERTYINFO_LOG_DESC)
    @RequestMapping(path = "/updatePropertyInfo",method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object updatePropertyInfo(PropertyProjectGetPropertyInfoDTO propertyDTO){
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetPropertyInfoDTO.class, request);
            if (null == propertyDTO){
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            //物业信息编号
            if(StringUtils.isBlank(propertyDTO.getPropertyInfoId())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_ID_EMPTY_ERR.getErrorCode());
            }
            //物业信息 类型判断
            if((null == propertyDTO.getPropertyType()) || (propertyDTO.getPropertyType() != PropertyInfoTypeEnum.CONVENIENCE_INFO.getType() &&
                    propertyDTO.getPropertyType() != PropertyInfoTypeEnum.NOTICE_INFO.getType())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_TYPE_INVALID_ERR.getErrorCode());
            }
            //物业标题
            if(StringUtils.isBlank(propertyDTO.getTitle())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_TITLE_EMPTY_ERR.getErrorCode());
            }
            //物业内容
            if(StringUtils.isBlank(propertyDTO.getPropertyInfo())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_EMPTY_ERR.getErrorCode());
            }
            iPropertyPropertyInfoServiceClient.updatePropertyInfo(propertyDTO);
            return new MessageVO(propertyDTO.getPropertyInfoId(),BaseErrorCodeEnum.SUCCESS.getErrorCode());

        } catch (Exception e) {
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】修改物业信息失败", e);
        }
    }

    /**
     * <desc>
     *      删除物业信息。
     * <desc/>
     *
     * @param propertyInfoIds 物业信息ID列表
     * @return
     * @author ZiXuan
     * @createDate 2017-11-02
     */
    @LoggerInfo(operateDesc = LogDescConstant.DELETE_PROPERTYINFO_LOG_DESC)
    @RequestMapping(path = "deletePropertyInfo", method = RequestMethod.POST)
    @ResponseBody
    @AuthAccessRequired
    public Object deletePropertyInfo(String propertyInfoIds){
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyInfoIds = request.getAttribute("propertyInfoIds") == null ? null : request.getAttribute("propertyInfoIds").toString();
            if (StringUtils.isBlank(propertyInfoIds)){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_ID_EMPTY_ERR.getErrorCode());
            }
            iPropertyPropertyInfoServiceClient.deletePropertyInfo(propertyInfoIds);
             MessageVO messageVO=new MessageVO(propertyInfoIds,BaseErrorCodeEnum.SUCCESS.getErrorCode());
             return messageVO;
        } catch (Exception e) {
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】删除物业信息失败", e);
        }
    }



    /**
     * <desc>
     *      移动端单条查询 物业信息
     * <desc/>
     *
     * @param propertyInfoId 查询参数
     * @return
     * @author ZiXuan
     * @createDate 2017-12-04
     */
    @RequestMapping(path = "/getOneInfoByApp",method = {RequestMethod.POST})
    @ResponseBody
    public Object getOneInfoByApp(String propertyInfoId, String userId) {
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            propertyInfoId = request.getAttribute("propertyInfoId") == null ? null : request.getAttribute("propertyInfoId").toString();
            userId = request.getAttribute("userId") == null ? null : request.getAttribute("userId").toString();
            //用户编号
            if(StringUtils.isBlank(userId)){
                return new MessageVO(PropertyErrorCodeEnum.USER_USER_USERID_NOT_NULL.getErrorCode());
            }

            //信息编号
            if(StringUtils.isBlank(propertyInfoId)){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_ID_EMPTY_ERR.getErrorCode());
            }
            //获取单条记录
            PropertyProjectPropertyInfoVO propertyProjectPropertyInfoVO = iPropertyPropertyInfoServiceClient.getOnePropertyInfo(propertyInfoId);

            //更新访问数
            PropertyProjectGetPropertyInfoDTO propertyProjectGetPropertyInfoDTO = new PropertyProjectGetPropertyInfoDTO();
            propertyProjectGetPropertyInfoDTO.setPropertyInfoId(propertyInfoId);

            Integer visitNum = 0;
            if (propertyProjectPropertyInfoVO.getVisitNum() == null){
                visitNum = 0;
            }
            else {
                visitNum = propertyProjectPropertyInfoVO.getVisitNum() + 1;
            }
            propertyProjectGetPropertyInfoDTO.setVisitNum(visitNum);
            iPropertyPropertyInfoServiceClient.updatePropertyInfo(propertyProjectGetPropertyInfoDTO);

            //app获取单条记录后 需写入数据库 保存浏览记录
            PropertyProjectGetPropertyInfoBrowseStatusDTO propertyProjectGetPropertyInfoBrowseStatusDTO = new PropertyProjectGetPropertyInfoBrowseStatusDTO();
            propertyProjectGetPropertyInfoBrowseStatusDTO.setPropertyInfoId(propertyInfoId);
            propertyProjectGetPropertyInfoBrowseStatusDTO.setUserId(userId);
            Page<PropertyProjectPropertyInfoBrowseStatusVO> page = iPropertyPropertyInfoServiceClient.getPropertyInfoBrowseStatusPage(propertyProjectGetPropertyInfoBrowseStatusDTO);
            if (page.getRows().size() <= 0){
                //第一次读取记录时 插入
                iPropertyPropertyInfoServiceClient.savePropertyInfoBrowseStatus(propertyProjectGetPropertyInfoBrowseStatusDTO);
            }

            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), propertyProjectPropertyInfoVO);

        } catch (Exception e) {
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】单条查询物业信息失败", e);
        }
    }


    /**
     * <desc>
     *      移动端查询物业信息
     * <desc/>
     * @param  pageDTO 查询物业信息数据传输对象
     * @return 物业信息 返回对象
     * @author ZiXuan
     * @createDate 2017-12-04
     */
    @RequestMapping(path = "/getPageByApp",method = RequestMethod.POST)
    @ResponseBody
    public Object getPageByApp(PropertyProjectGetPropertyInfoDTO pageDTO, String userId){
        try {
            HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
            pageDTO = HttpProtocolUtil.parseRequestParamToDTO(PropertyProjectGetPropertyInfoDTO.class, request);
            userId = request.getAttribute("userId") == null ? null : request.getAttribute("userId").toString();
            if (null == pageDTO){
                return new MessageVO(BaseErrorCodeEnum.NOT_PARAM.getErrorCode());
            }
            //用户编号
            if(StringUtils.isBlank(userId)){
                return new MessageVO(PropertyErrorCodeEnum.USER_USER_USERID_NOT_NULL.getErrorCode());
            }

            //项目编号
            if(StringUtils.isBlank(pageDTO.getProjectId())){
                return new MessageVO(PropertyErrorCodeEnum.PUB_PROJECT_ID_EMPTY_ERR.getErrorCode());
            }

            //物业信息 类型判断
            if((null != pageDTO.getPropertyType()) && (pageDTO.getPropertyType() != PropertyInfoTypeEnum.NOTICE_INFO.getType() &&
                    pageDTO.getPropertyType() != PropertyInfoTypeEnum.CONVENIENCE_INFO.getType())){
                return new MessageVO(PropertyErrorCodeEnum.PROJECT_PROPERTY_INFO_TYPE_INVALID_ERR.getErrorCode());
            }

            Page<PropertyProjectPropertyInfoVO> page = new Page<>();
            List<Integer> propertyTypeList = new ArrayList<>();

            if (null == pageDTO.getPropertyType()){        //默认查询报修和投诉
                propertyTypeList.add(PropertyInfoTypeEnum.NOTICE_INFO.getType());
                propertyTypeList.add(PropertyInfoTypeEnum.CONVENIENCE_INFO.getType());
            }
            else
            {
                propertyTypeList.add(pageDTO.getPropertyType());
            }

            pageDTO.setPropertyTypeList(propertyTypeList);

            //查询 物业信息
            page = iPropertyPropertyInfoServiceClient.getPage(pageDTO);

            //查询物业信息 浏览记录
            PropertyProjectGetPropertyInfoBrowseStatusDTO propertyProjectGetPropertyInfoBrowseStatusDTO = new PropertyProjectGetPropertyInfoBrowseStatusDTO();
            propertyProjectGetPropertyInfoBrowseStatusDTO.setUserId(userId);
            Page<PropertyProjectPropertyInfoBrowseStatusVO> pageBrowseStatus = iPropertyPropertyInfoServiceClient.getPropertyInfoBrowseStatusPage(propertyProjectGetPropertyInfoBrowseStatusDTO);
            List<String> listPropertyInfoId = new ArrayList<>();
            for (PropertyProjectPropertyInfoBrowseStatusVO oneInfo : pageBrowseStatus.getRows()){
                listPropertyInfoId.add(oneInfo.getPropertyInfoId());
            }

            //重新组装  物业信息和浏览状态
            List<PropertyProjectPropertyInfoAndBrowseStatusVO> listResult = new ArrayList<>();
            for (PropertyProjectPropertyInfoVO currentInfo : page.getRows()){
                PropertyProjectPropertyInfoAndBrowseStatusVO oneInfo = new PropertyProjectPropertyInfoAndBrowseStatusVO();
                BeanUtils.copyProperties(currentInfo, oneInfo);

                oneInfo.setBrowseStatus(0);  //0未浏览
                if (listPropertyInfoId.contains(currentInfo.getPropertyInfoId())){
                    oneInfo.setBrowseStatus(1); //1已浏览
                }

                listResult.add(oneInfo);
            }
            Page<PropertyProjectPropertyInfoAndBrowseStatusVO> pageResult = new Page<>();
            pageResult.setRows(listResult);

            return new MessageVO(BaseErrorCodeEnum.SUCCESS.getErrorCode(), pageResult);

        } catch (Exception e) {
            throw new DataAccessException("【物业_系统设置_物业通知便民信息】分页查询物业信息失败", e);
        }
    }
}
